﻿<UserControl x:Class="Gallery.AlbumView" 
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
		xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
		mc:Ignorable="d"
		d:DesignWidth="640" d:DesignHeight="480"
		xmlns:vm="clr-namespace:Gallery.ViewModels"
		>
	<!--
	xmlns:vml="clr-namespace:MefMvvm.ViewModelLocator;assembly=MefMvvm"
	vml:ViewModelLocator.ViewModel="AlbumViewModel"
	-->
	<UserControl.DataContext>
		<vm:AlbumViewModel/>
	</UserControl.DataContext>
	<UserControl.Resources>

		<Style x:Key="PhotoLinkTitle" TargetType="TextBlock">
			<Setter Property="Grid.Row" Value="1" />
			<Setter Property="HorizontalAlignment" Value="Left" />
			<Setter Property="FontFamily" Value="Arial" />
			<Setter Property="FontSize" Value="12" />
			<Setter Property="Foreground" Value="Silver" />
			<Setter Property="Margin" Value="8,4,0,0" />
		</Style>

		<Style x:Key="PhotoLinkStyle" TargetType="HyperlinkButton">
			<Setter Property="Grid.Column" Value="1" />
			<Setter Property="HorizontalAlignment" Value="Right" />
			<Setter Property="VerticalAlignment" Value="Center" />
			<Setter Property="Margin" Value="5,0,35,20" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="HyperlinkButton">
						<StackPanel>
							<Viewbox MaxHeight="{Binding PhotoWidth, Source={StaticResource Globals}}" MaxWidth="{Binding PhotoWidth, Source={StaticResource Globals}}" HorizontalAlignment="Center" VerticalAlignment="Bottom" Stretch="Uniform">
								<Image x:Name="PhotoImage" Source="{Binding ImageUrl}" Cursor="Hand" />
							</Viewbox>
							<Grid Visibility="{Binding PhotoTitleVisibility}">
								<Grid.RowDefinitions>
									<RowDefinition Height="25" />
								</Grid.RowDefinitions>

								<Viewbox Height="{Binding PhotoWidth}" MaxWidth="{Binding PhotoWidth}" HorizontalAlignment="Center" VerticalAlignment="Top" Stretch="Uniform">
									<Image x:Name="PhotoImageReflection" Source="{Binding ImageUrl}" Cursor="Hand">
										<Image.RenderTransform>
											<ScaleTransform ScaleY="-1"></ScaleTransform>
										</Image.RenderTransform>
									</Image>
								</Viewbox>
								<Border x:Name="TitleBorder" Opacity=".7" VerticalAlignment="Top">
									<Border.Background>
										<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
											<GradientStop Color="#FF000000" Offset="0.0"/>
											<GradientStop Color="#FF000000" Offset="1.0"/>
										</LinearGradientBrush>
									</Border.Background>
									<TextBlock x:Name="Title" Text="{Binding Title}" FontSize="{Binding PhotoTitleFontSize}" Style="{StaticResource PhotoLinkTitle}" />
								</Border>
							</Grid>
						</StackPanel>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

		<DataTemplate x:Key="PhotoTemplate">
			<HyperlinkButton x:Name="PhotoLink" Style="{StaticResource PhotoLinkStyle}" Width="Auto" Height="Auto" NavigateUri="{Binding ID}" />
		</DataTemplate>

	</UserControl.Resources>
	<Grid x:Name="LayoutRoot" HorizontalAlignment="Center">

		<ListBox x:Name="PhotoList"
			ItemsSource="{Binding Photos}"
			Style="{StaticResource WrapListBox}"
			ItemTemplate="{StaticResource PhotoTemplate}"
			Margin="4" Background="Black" />

	</Grid>
</UserControl>
